package com.zhihuichongcheng.application.util;

import android.content.Context;
import android.os.Handler;


/**
 * Created by admin on 2015/10/20.
 */
public class SMSVerifyUtil {

    private static SMSVerifyUtil sInstance = null;

    private final String CountryCode = "+86";

    private Handler mHandler = null;


//    private EventHandler mEventHandler = new EventHandler() {
//        @Override
//        public void afterEvent(int event, int result, Object data) {
//            if (result == SMSSDK.RESULT_COMPLETE) {
//                if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
//                    mHandler.sendEmptyMessage(Constants.Handler_VerifySMSCode_Success);
//                } else if (event == SMSSDK.EVENT_GET_VERIFICATION_CODE) {
//                    boolean smart = (Boolean) data;
//                    if (smart) {
//                        //通过智能验证
//                        mHandler.sendEmptyMessage(Constants.Handler_getSMSCode_Intelligent_Success);
//                    } else {
//                        //依然走短信验证
//                        mHandler.sendEmptyMessage(Constants.Handler_GetSMSCode_Success);
//                    }
//
//                }
//            } else if (result == SMSSDK.RESULT_ERROR) {
//                if (event == SMSSDK.EVENT_SUBMIT_VERIFICATION_CODE) {
//                    try {
//                        Throwable throwable = (Throwable) data;
//                        JSONObject jsonObject = new JSONObject(throwable.getMessage());
//
//                        Message message = new Message();
//                        message.what = Constants.Handler_VerifySMSCode_Failure;
//                        message.obj = jsonObject.getString("detail");
//                        mHandler.sendMessage(message);
//                    } catch (JSONException e) {
//                        e.printStackTrace();
//                    }
//
//                } else if (event == SMSSDK.EVENT_GET_VERIFICATION_CODE) {
//                    try {
//                        Throwable throwable = (Throwable) data;
//                        JSONObject jsonObject = new JSONObject(throwable.getMessage());
//
//                        Message message = new Message();
//                        message.what = Constants.Handler_GetSMSCode_Failure;
//                        message.obj = jsonObject.getString("detail");
//                        mHandler.sendMessage(message);
//                    } catch (JSONException e) {
//                        e.printStackTrace();
//                    }
//
//                }
//            }
//        }
//    };

    private SMSVerifyUtil() {

    }

    public static SMSVerifyUtil getInstance() {
        if (sInstance == null) sInstance = new SMSVerifyUtil();
        return sInstance;

    }

    public void initSdk(Context context, String appKey, String appSecret) {
//        SMSSDK.initSDK(context, appKey, appSecret);
//        SMSSDK.registerEventHandler(mEventHandler);
    }

    public void getSMS(String phoneNum) {

//        SMSSDK.getVerificationCode(CountryCode, phoneNum);

    }

    public void virifySMS(String phoneNum, String smsCode) {
//        SMSSDK.submitVerificationCode(CountryCode, phoneNum, smsCode);

    }

    public void setHandler(Handler handler) {
        this.mHandler = handler;
    }

}
